package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class BorrowOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("借阅图书");

        Scanner in = new Scanner(System.in);
        System.out.println("输入要借的书名");
        String name = in.nextLine();
        int currentSize = bookList.getUsedSize();
        int exist = -1; //用以标记书是否存在
        for(int i = 0; i <currentSize; i++){
            Book book = bookList.getBooks(i);
            if(book.getName().equals(name)){
                exist = 1;
                book.setIsborrow(true);
                break;
            }
        }
        if(exist == -1)
        {
            System.out.println("没有这本书");
        }
        System.out.println("借阅成功");
    }
}
